// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Requests;
using Elastic.Clients.Elasticsearch.Serialization;
using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement;

public sealed partial class MoveToStepRequestParameters : RequestParameters
{
}

/// <summary>
/// <para>Manually moves an index into the specified step and executes that step.</para>
/// </summary>
public sealed partial class MoveToStepRequest : PlainRequest<MoveToStepRequestParameters>
{
	public MoveToStepRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r.Required("index", index))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.IndexLifecycleManagementMoveToStep;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ilm.move_to_step";

	[JsonInclude, JsonPropertyName("current_step")]
	public Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKey? CurrentStep { get; set; }
	[JsonInclude, JsonPropertyName("next_step")]
	public Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKey? NextStep { get; set; }
}

/// <summary>
/// <para>Manually moves an index into the specified step and executes that step.</para>
/// </summary>
public sealed partial class MoveToStepRequestDescriptor<TDocument> : RequestDescriptor<MoveToStepRequestDescriptor<TDocument>, MoveToStepRequestParameters>
{
	internal MoveToStepRequestDescriptor(Action<MoveToStepRequestDescriptor<TDocument>> configure) => configure.Invoke(this);

	public MoveToStepRequestDescriptor(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r.Required("index", index))
	{
	}

	public MoveToStepRequestDescriptor() : this(typeof(TDocument))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.IndexLifecycleManagementMoveToStep;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ilm.move_to_step";

	public MoveToStepRequestDescriptor<TDocument> Index(Elastic.Clients.Elasticsearch.IndexName index)
	{
		RouteValues.Required("index", index);
		return Self;
	}

	private Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKey? CurrentStepValue { get; set; }
	private Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor CurrentStepDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor> CurrentStepDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKey? NextStepValue { get; set; }
	private Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor NextStepDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor> NextStepDescriptorAction { get; set; }

	public MoveToStepRequestDescriptor<TDocument> CurrentStep(Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKey? currentStep)
	{
		CurrentStepDescriptor = null;
		CurrentStepDescriptorAction = null;
		CurrentStepValue = currentStep;
		return Self;
	}

	public MoveToStepRequestDescriptor<TDocument> CurrentStep(Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor descriptor)
	{
		CurrentStepValue = null;
		CurrentStepDescriptorAction = null;
		CurrentStepDescriptor = descriptor;
		return Self;
	}

	public MoveToStepRequestDescriptor<TDocument> CurrentStep(Action<Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor> configure)
	{
		CurrentStepValue = null;
		CurrentStepDescriptor = null;
		CurrentStepDescriptorAction = configure;
		return Self;
	}

	public MoveToStepRequestDescriptor<TDocument> NextStep(Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKey? nextStep)
	{
		NextStepDescriptor = null;
		NextStepDescriptorAction = null;
		NextStepValue = nextStep;
		return Self;
	}

	public MoveToStepRequestDescriptor<TDocument> NextStep(Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor descriptor)
	{
		NextStepValue = null;
		NextStepDescriptorAction = null;
		NextStepDescriptor = descriptor;
		return Self;
	}

	public MoveToStepRequestDescriptor<TDocument> NextStep(Action<Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor> configure)
	{
		NextStepValue = null;
		NextStepDescriptor = null;
		NextStepDescriptorAction = configure;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (CurrentStepDescriptor is not null)
		{
			writer.WritePropertyName("current_step");
			JsonSerializer.Serialize(writer, CurrentStepDescriptor, options);
		}
		else if (CurrentStepDescriptorAction is not null)
		{
			writer.WritePropertyName("current_step");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor(CurrentStepDescriptorAction), options);
		}
		else if (CurrentStepValue is not null)
		{
			writer.WritePropertyName("current_step");
			JsonSerializer.Serialize(writer, CurrentStepValue, options);
		}

		if (NextStepDescriptor is not null)
		{
			writer.WritePropertyName("next_step");
			JsonSerializer.Serialize(writer, NextStepDescriptor, options);
		}
		else if (NextStepDescriptorAction is not null)
		{
			writer.WritePropertyName("next_step");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor(NextStepDescriptorAction), options);
		}
		else if (NextStepValue is not null)
		{
			writer.WritePropertyName("next_step");
			JsonSerializer.Serialize(writer, NextStepValue, options);
		}

		writer.WriteEndObject();
	}
}

/// <summary>
/// <para>Manually moves an index into the specified step and executes that step.</para>
/// </summary>
public sealed partial class MoveToStepRequestDescriptor : RequestDescriptor<MoveToStepRequestDescriptor, MoveToStepRequestParameters>
{
	internal MoveToStepRequestDescriptor(Action<MoveToStepRequestDescriptor> configure) => configure.Invoke(this);

	public MoveToStepRequestDescriptor(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r.Required("index", index))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.IndexLifecycleManagementMoveToStep;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ilm.move_to_step";

	public MoveToStepRequestDescriptor Index(Elastic.Clients.Elasticsearch.IndexName index)
	{
		RouteValues.Required("index", index);
		return Self;
	}

	private Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKey? CurrentStepValue { get; set; }
	private Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor CurrentStepDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor> CurrentStepDescriptorAction { get; set; }
	private Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKey? NextStepValue { get; set; }
	private Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor NextStepDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor> NextStepDescriptorAction { get; set; }

	public MoveToStepRequestDescriptor CurrentStep(Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKey? currentStep)
	{
		CurrentStepDescriptor = null;
		CurrentStepDescriptorAction = null;
		CurrentStepValue = currentStep;
		return Self;
	}

	public MoveToStepRequestDescriptor CurrentStep(Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor descriptor)
	{
		CurrentStepValue = null;
		CurrentStepDescriptorAction = null;
		CurrentStepDescriptor = descriptor;
		return Self;
	}

	public MoveToStepRequestDescriptor CurrentStep(Action<Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor> configure)
	{
		CurrentStepValue = null;
		CurrentStepDescriptor = null;
		CurrentStepDescriptorAction = configure;
		return Self;
	}

	public MoveToStepRequestDescriptor NextStep(Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKey? nextStep)
	{
		NextStepDescriptor = null;
		NextStepDescriptorAction = null;
		NextStepValue = nextStep;
		return Self;
	}

	public MoveToStepRequestDescriptor NextStep(Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor descriptor)
	{
		NextStepValue = null;
		NextStepDescriptorAction = null;
		NextStepDescriptor = descriptor;
		return Self;
	}

	public MoveToStepRequestDescriptor NextStep(Action<Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor> configure)
	{
		NextStepValue = null;
		NextStepDescriptor = null;
		NextStepDescriptorAction = configure;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (CurrentStepDescriptor is not null)
		{
			writer.WritePropertyName("current_step");
			JsonSerializer.Serialize(writer, CurrentStepDescriptor, options);
		}
		else if (CurrentStepDescriptorAction is not null)
		{
			writer.WritePropertyName("current_step");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor(CurrentStepDescriptorAction), options);
		}
		else if (CurrentStepValue is not null)
		{
			writer.WritePropertyName("current_step");
			JsonSerializer.Serialize(writer, CurrentStepValue, options);
		}

		if (NextStepDescriptor is not null)
		{
			writer.WritePropertyName("next_step");
			JsonSerializer.Serialize(writer, NextStepDescriptor, options);
		}
		else if (NextStepDescriptorAction is not null)
		{
			writer.WritePropertyName("next_step");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKeyDescriptor(NextStepDescriptorAction), options);
		}
		else if (NextStepValue is not null)
		{
			writer.WritePropertyName("next_step");
			JsonSerializer.Serialize(writer, NextStepValue, options);
		}

		writer.WriteEndObject();
	}
}